package com.wang.controller;

import com.wang.service.ApiService;
import org.springframework.web.bind.annotation.*;


import javax.annotation.Resource;



/**
 * @Author wangf
 * @Description TODO
 * @Date 2023/2/19 14:19
 */
@RestController
@RequestMapping("/")
public class ApiController {
    @Resource
    private ApiService apiService;

    /**
     *  调用ChatGPT接口
     * @param message
     * @return  String
     */
    @GetMapping("/chat")
    public String chat(@RequestParam String message){
        return  apiService.createCompletion(message);
    }

    /**
     * 设置chatGPT key
     * @param key
     * @return String
     */
    @PostMapping("/setKey")
    public String setKey(@RequestParam String key){
        return  apiService.setKey(key);
    }
}
